package flyweight;

public class GameTestMain {
    public static void main(String[] args) {
        TreeTypeFactory flyweightFactory = new TreeTypeFactory();

        // 由工厂生产内在状态的东西，即生产 TreeType
        TreeType pineFlyweight = flyweightFactory.getTreeType("pine", "green", "smooth");
        TreeType oakFlyweight = flyweightFactory.getTreeType("oak", "brown", "rough");

        // 位置信息 (x,y) 是外在状态，由客户端提供。
        Tree pineTree1 = new Tree(pineFlyweight, 100, 200);
        Tree pineTree2 = new Tree(pineFlyweight, 150, 300);
        Tree oakTree = new Tree(oakFlyweight, 200, 400);

        pineTree1.draw();
        pineTree2.draw();
        oakTree.draw();
    }
}
